<!--
 * @Description: 复制文章页弹窗
 * @Autor: starzhou
 * @Date: 2020-09-02 11:58:29
 * @LastEditTime: 2020-09-09 14:59:43
-->
<style scoped>
* {
  margin: 0 0;
  padding: 0 0;
}
ul li {
  list-style: none;
}
.modalDetail {
  display: flex;
}
.layer {
  width: 100%;
  height: 100%;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: 999;
}
.warnUserList {
  background: #fff;
  width: 375px;
  height: 450px;
  position: fixed;
  left: 50%;
  margin-left: -228px;
  top: 40%;
  margin-top: -175px;
  z-index: 9999;
  border: 1px solid #ccd5f2;
  box-shadow: 0 0 10px 1px #e5e5e5;
}
.canWarn-list {
  height: 300px;
  overflow-x: hidden;
  border: 1px solid #e4e4e4;
  margin: 20px;
  overflow-y: auto;
}
.warnUserList .checkbox {
  cursor: pointer;
  text-align: left;
  display: inline-block;
  color: #666;
  width: 100%;
  margin-left: 10px;
}
.warnUserList .checkbox:hover span {
  color: #2277da;
}
.warnUserList .simulation {
  width: 15px;
  height: 15px;
  background: url("../../assets/images/check.png") no-repeat center center;
  display: inline-block;
  vertical-align: middle;
  margin: 2px 20px 0 0;
  float: right;
}
.warnUserList .simulation2 {
  background: url("../../assets/images/checked.png") no-repeat center center;
}
.warnUserList .checkbox .warnCheckBox {
  display: block;
  width: 15px;
  height: 15px;
  cursor: pointer;
  position: absolute;
  z-index: 3;
  visibility: hidden;
  border: none;
  right: 20px;
  top: 12px;
}
.canWarn-list .checkbox span {
  float: left;
  display: inline-block;
  width: auto;
  margin: 0 0 0 20px;
  max-width: 170px;
  text-overflow: ellipsis;
  overflow: hidden;
  word-break: keep-all;
}
.warnUserList li {
  margin: 10px 0 0 0;
}
.yujinglist-button {
  text-align: center;
  margin-top: 6px;
}
.yujinglist-button input {
  border: none;
  color: #333;
  background: #ddd;
  width: 52px;
  height: 26px;
  line-height: 26px;
  display: inline-block;
  cursor: pointer;
  transition: all ease 0.3s;
  border-radius: 3px;
}
.yujinglist-button input:hover {
  background: #cfcfcf;
}
.yujinglist-button .btn-warn-submit {
  margin: 0 15px 0 20px;
  background: #2277da;
  color: #fff;
}
.yujinglist-button .btn-warn-submit:hover {
  background: #1d6ac1;
}
/* 专题监测信息列表页预警弹窗样式 */
.warnUserList .modalTitle {
  display: flex;
  height: 40px;
  justify-content: space-between;
  border-bottom: 1px solid #e4e4e4;
}
.warnUserList .modalTitle p {
  display: inline-block;
  height: 40px;
  line-height: 40px;
  font-size: 18px;
  font-weight: 600;
  margin-left: 20px;
}
.warnUserList .modalTitle p:last-child {
  margin-right: 20px;
  cursor: pointer;
}
.warnUserList .modalDetail {
  display: flex;
}
.warnUserList .modalDetail .modalLeft {
  width: 100%;
}
.warnUserList .modalDetail .modalLeft .canWarn-list li .checkbox {
  cursor: pointer;
  text-align: left;
  display: inline-block;
  color: #666;
  width: 100%;
  margin-left: 10px;
}
.warnUserList .modalDetail .modalLeft .canWarn-list li .checkbox .simulation {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: middle;
}
.warnUserList .modalDetail .modalLeft .canWarn-list li .checkbox span {
  display: inline-block;
  width: auto;
  max-width: 170px;
  text-overflow: ellipsis;
  vertical-align: middle;
  overflow: hidden;
  word-break: keep-all;
}

.ssk-main {
  display: block;
  margin: 20px auto 0 auto;
  width: 335px;
}
.ssk-main input:focus {
  border: 1px solid #2177da;
}
.ssk-main input {
  border: 1px solid #ccd5f2;
  border-radius: 3px;
  height: 24px;
  line-height: 24px;
  padding: 0 10px;
  width: 140px;
  margin-right: 10px;
}
.ssk-wbqd {
  border: 1px solid #ccd5f2;
  border-radius: 3px;
  color: #333;
  height: 24px;
  line-height: 24px;
  width: 50px;
  display: inline-block;
  text-align: center;
  cursor: pointer;
}
.ssk-wbqd:hover {
  background: #2377da;
  color: #fff;
  border: 1px solid #2377da;
}
.ssk-ssan {
  background: #ff8901;
  color: #fff;
  border: 1px solid #ff8901;
  border-radius: 3px;
  height: 24px;
  line-height: 24px;
  width: 50px;
  display: inline-block;
  text-align: center;
  cursor: pointer;
  float: right;
}
.ssk-ssan:hover {
  background: #f38100;
}
</style>
<template>
  <div v-if="isShow">
    <div class="layer" @click="hideProps"></div>
    <div class="warnUserList">
      <div class="modalTitle">
        <p>收藏到</p>
        <p class="closeModal" @click="hideProps">
          <i class="el-icon-close"></i>
        </p>
      </div>
      <div class="modalDetail">
        <div class="modalLeft">
          <ul class="canWarn-list">
            <li @click="handleOptions(item)" v-for="(item, index) in objList" :key="index">
              <label class="checkbox">
                <div :class="['simulation', folderId == item.id ? 'simulation2' : '']"></div>
                <span>{{item.folderName}}</span>
              </label>
            </li>
          </ul>
        </div>
      </div>
      <div class="ssk-main">
        <input placeholder="输入名称新建收藏夹" v-model="folderName" type="text" />
        <span class="ssk-wbqd" @click="addFolder">确定</span>
        <span class="ssk-ssan" @click="subInfo">收藏</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "collect-prop",
  props: {
    isShow: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      objList: [],
      folderId: 0,
      folderName: "",
      collectList: [],
    };
  },
  watch: {
    isShow() {
      if (!this.isShow) {
        this.objList = [];
        this.folderId = 0;
        this.folderName = "";
        this.collectList = [];
      }
    },
  },
  methods: {
    handleOptions(item) {
      if (this.folderId != item.id) {
        this.$set(this, "folderId", item.id);
      } else {
        this.$set(this, "folderId", 0);
      }
    },
    hideProps() {
      this.$emit("update:isShow", false);
    },
    subInfo() {
      let { folderId, collectList } = this;
      if (folderId == 0) {
        this.$message("请先选择收藏夹");
        return;
      }
      this.$emit("sendMessage", { folderId, collectList });
    },
    addFolder() {
      let { folderName } = this;
      if (!folderName) {
        this.$message("请先输入收藏夹名");
        return;
      }
      this.$emit("addFolder", { folderName });
    },
  },
};
</script>